<template>
  <div class="app-container" style="padding: 0;box-shadow: 0 0 0;margin: 0 15px;">
    <drug-table style="margin-top:15px"  @getSelection="getSelection"  :isMultipleSelection="true" :backCount="backCount" @emitSpanFun="emitSpanFun"  @getBackData="getList" :tableData="tableData" :tableLoading="tableLoading" :tableHeader="tableHeader" :option="option">
      <template slot-scope="props" slot="operate">
        <div >
          <label @click="openMyTaskDialog(props.rowData)"
                 class="table-view">
            查看
          </label>
        </div>
      </template>
    </drug-table>
  </div>
</template>

<script>
import waves from '@/views/directive/waves' // waves directive
import { formatDate } from '@/utils/formatDate'
import drugTable from "@/components/table/index";
import {getToken} from '@/utils/auth' // 验权
export default {
  components: { drugTable},
  directives: { waves },
  data() {
    return {
      tableData: [],
      tableHeader:[],
      tableLoading:true,
      option:{showOperate:false},
      searchParam: {

      },
      selectChoice:[],
      backCount:0,
    }
  },
  mounted() {

  },
  methods: {
    searchList(params){
      for(let key in params){
        this.searchParam[key] = params[key]
      }
      this.getList(0,20);
    },
    getSelection(val){
      this.selectChoice = val;
    },
    openMyTaskDialog(data){
      let row = Object.assign({},data);
      this.$eventBus.$emit("openMyTaskDialog", row, "see",data.testStaffId);
    },

    getList(startIndex,pageRow) {
      let self = this;
      self.tableLoading = true;
      let searchParam = Object.assign({}, this.searchParam);
      if (searchParam.endTime) {
        searchParam.endTime = searchParam.endTime + " 23:59:59";
      }
      let start = typeof startIndex == "number" ? startIndex : 0;
      let total = typeof pageRow == "number" ? pageRow : 15;
      searchParam.startIndex = start;
      searchParam.totalPage = total;
      searchParam.status = "AP";
      searchParam.userId = self.$store.getters.userId;
      self.$http({
        url: "/drug/sampleItem/querySampleItemList",
        method: "post",
        params: searchParam
      }).then(resp => {
        if (resp.success) {
          for (let data of resp.result) {
            data.itemCount = data.singleCount + "/" + data.totalCount;
            if(data.checkStatus == 'ZZ'){
              data.color = 'task_red'
            }
          }
          self.tableLoading = false;
          self.tableData = resp.result;
          if (self.tableData.length > 0) {
            self.backCount = self.tableData[0].count;
          } else {
            self.backCount = 0;
          }
          self.tableHeader = [
            {"columnName": "sampleId", "coloumNameCn": "检验单号"},
            {"columnName": "deptName", "coloumNameCn": "申请部门"},
            {"columnName": "userName", "coloumNameCn": "申请人", "width": "70px"},
            {"columnName": "createTimeSecondFt", "coloumNameCn": "送检时间"},
            {"columnName": "materialCode", "coloumNameCn": "物料编码"},
            {"columnName": "materialName", "coloumNameCn": "样品名称"},
            {"columnName": "sampleNum", "coloumNameCn": "样品批号"},
            {"columnName": "materialType", "coloumNameCn": "样品规格"},
            {"columnName": "materialGrade", "coloumNameCn": "样品等级"},
            {"columnName": "location", "coloumNameCn": "地点"},
            {"columnName": "itemCount", "coloumNameCn": "检项数"},
            {"columnName": "resultIdCn", "coloumNameCn": "结果录入"},
            {"columnName": "updateTimeFt", "coloumNameCn": "录入时间"},
            {"columnName": "checkStatusCn", "coloumNameCn": "状态", "isClick": true},];
          self.option.showOperate = false;
        }
      });
    },
    emitSpanFun(row){
      let self = this;
      self.$http({
        url: "/drug/fmApprove/queryFmApproveByRelateId",
        method: "post",
        params:{relateId:row.sId}
      }).then(resp => {
        if (resp.success) {
          this.$alert(resp.result.content, '审核意见');
        }
      });
    },

  },
}
</script>


<style lang="scss" scoped>
.el-form-no {
  text-align: right;
  font-size: 18px;
  color: #cb0000;
}

.el-dialog .el-button--primary {
  background-color: #2e827f;
  border-color: #2e827f;
    border-radius: 3px;
    padding: 5px 10px;
}
.same-contrast {
	background: #2e827f;
	&:hover {
		opacity: .8;
	}
}

</style>
